<?php

use think\migration\Migrator;
use think\migration\db\Column;

class DealerOrder extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('dealer_order', ['engine' => 'InnoDB', 'comment'=> '经销商采购订单','collation' => 'utf8mb4_general_ci']);
        $table->addColumn('order_no', 'string', ['limit' => 32, 'default' => '', 'comment' => '订单号'])
              ->addColumn('company_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '公司id'])
              ->addColumn('dealer_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '经销商id'])
              ->addColumn('supplier_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '供应商id'])
              ->addColumn('company_user_id', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '公司用户id'])
              ->addColumn('order_status', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '订单状态'])
              ->addColumn('order_amount', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => 0.00, 'comment' => '订单金额'])
              ->addColumn('pay_amount', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => 0.00, 'comment' => '应付金额'])
              ->addColumn('pay_status', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '支付状态'])
              ->addColumn('pay_type', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '支付方式'])
              ->addColumn('pay_time', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '支付时间'])
              ->addColumn('create_time', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '创建时间'])
              ->addColumn('update_time', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '更新时间'])
              ->addColumn('delete_time', 'integer', ['limit' => 10, 'default' => 0, 'comment' => '删除时间'])
              ->addIndex('order_no')
              ->addIndex('company_id')
              ->addIndex('dealer_id')
              ->addIndex('supplier_id')
              ->addIndex('company_user_id')
              ->create();


    }
}
